<template>
  <div>
    <van-nav-bar class="page-nav-bar">
      <van-button slot="title" class="search-btn" type="info" icon="search" round>搜索</van-button>
    </van-nav-bar>
    <van-tabs v-model="active" class="my-tabs" animated swipeable>
      <van-tab v-for="(item,index) in channels" :key="index" :title="item.name">
        <table-item :query-obj="item" />
      </van-tab>
      <div slot="nav-right" class="place" />
      <div slot="nav-right" class="hmg-icon">
        <i class="iconfont icon-gengduo" />
      </div>
    </van-tabs>
  </div>
</template>
<script>
import { getChannels } from '@/api/user'
import TableItem from '@/components/TableItem'
export default {
  name: 'HomeIndex',
  components: {
    TableItem
  },
  data() {
    return {
      active: 0,
      channels: []
    }
  },
  created() {
    this.loadChannels()
  },
  methods: {
    async loadChannels() {
      try {
        const res = await getChannels()
        this.channels = res.data.data.channels
      } catch (err) { this.$toast(err.message) }
    }

  }
}
</script>
<style lang="less" scoped>
.page-nav-bar {
  ::v-deep .van-nav-bar__title {
    max-width: unset !important;
  }
  .search-btn {
    width: 555px;
    height: 64px;
    background: #5babfb;
    border: none;
    font-size: 28px;
    .van-icon {
      font-size: 32px;
    }
  }

}
.my-tabs{
  .hmg-icon{
    width:66px;
    height: 82px;
    position: fixed;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fff;
    opacity: 0.902;
    i{
      font-size: 32px;
    }
  }
  .place{
    width:66px;
    height: 82px;
    flex-shrink: 0;
  }
}
</style>
